import React, { useEffect } from 'react'
import { StyleSheet, Image, StatusBar, View } from 'react-native'

const Splash = ({ navigation }) => {

  // 当组件加载时创建一个计时器
  useEffect(() => {
    setTimeout(() => {
      // replace：销毁当前页，跳转到下个页面
      navigation.replace('Index')
    }, 3000)
  }, [navigation])

  return (
    <View style={styles.splash}>
      <StatusBar hidden={true} />
      <Image source={require('../images/splash.jpg')} />
    </View>
  )
}

export default Splash

const styles = StyleSheet.create({
  splash: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: '#1C0E1B',
  }
})
